How-to: Use Monero with Wallet Isolation in Qubes-Whonix

From Whonix
Jump to navigation Jump to search
Documentation Previous page: Monero Index page: Documentation Next page: UnstoppableSwap How-to: Use Monero with Wallet Isolation in Qubes-Whonix
Monero
Monero Logo

Isolate the network part (monerod) from the wallet part (Monero Wallet) for better security.

Introduction

[edit]

This instruction document explains how to isolate the network part (monerod) from the wallet part (Monero Wallet) for better security. monerod is the Monero daemon, a full blockchain-verifying background process which downloads and verifies the whole blockchain.

The advantage of this setup is that, should there ever be a vulnerability that allows the exploitation of monerod by malware, all user funds would remain safe, since these would remain isolated in Monero Wallet in a different VM.

If monerod was ever compromised, then this setup would have the same issues as described on the Monero wiki page in chapter Remote Node Security and Privacy Considerations. This issue is unspecific to these instructions.

The connection scheme is Monero WalletmonerodTorMonero network.

Instructions on this wiki page are compatible with the Whonix isolating proxy feature, i.e. after disabling transparent proxying.

Inappropriate Use of Root Rights should be avoided. Instructions on this wiki page have been carefully crafted with when to use sudo and when not to use it in mind. The user should not use sudo unless instructed in documentation. [1]

Warning: This is for testers-only!

Credits: These instructions are based on How to use Monero CLI/daemon with Qubes + Whonixarchive.org iconarchive.today icon by getmonero.orgarchive.org iconarchive.today icon.

Prerequisite Knowledge

[edit]

Since this setup is more complex and intended for advanced users only, it is highly recommended to first acquire essential knowledge about using Monero by following the "normal", simpler instructions on the Monero wiki page, without reference to the instructions on this wiki page. Only after the essential knowledge has been acquired should the more complex setup documented on this wiki page be layered on top.

Practicing with a small amount of value is recommended, but not too small (below the dust level, making it impossible to move funds because the funds are worth less than the required transaction fees). Practicing on Monero testnet first should also be considered. This is unspecific to Whonix.

1 Optional. How to use Monero Wallet GUI.

If the end-goal is using an offline (airgap) Monero Wallet, learning how to use Monero Wallet GUI would be expendable.

2 How to use Monero Wallet CLI.

Wallet creation, receiving funds, spending funds.

3 Done.

The prerequisite knowledge topics have been listed.

Update Required

[edit]

These instructions were written when monerod and monero-wallet-cli were available in /usr/bin. Nowadays, these are not available there by default.

TODO: rewrite this guide to use Monero from flatpak or by installing these tools to /usr/bin (update Monero/Manual Instructions)

Setup

[edit]

Qubes dom0 Configuration

[edit]

Create App Qubes

[edit]

In dom0.

It is easier to use the exact same names as in the example below in this chapter. Otherwise, adjustments in the next chapter, "Qubes qrexec Policy Configuration", would be required.

Qubes VM ManagerVMCreate App Qube

  • Create Qubes-Whonix-Workstation App Qube
    • Name: monero-wallet-ws.
    • Color: Choose a color label for the Whonix-Workstation App Qube. Optional suggestion: yellow
    • Use this template: Choose the Whonix-Workstation Template. For example: whonix-workstation-18.
    • Standalone: Leave the Standalone field unchecked.
    • Type: Choose the type App Qube.
    • Allow networking: Choose none.
    • Press: OK.

Qubes VM ManagerVMCreate App Qube

  • Create monerod-ws App Qube
    • Name: monerod-ws.
    • Color: Choose a color label for the Whonix-Workstation App Qube. Optional suggestion: red
    • Use this template: Choose the Whonix-Workstation Template. For example: whonix-workstation-18.
    • Standalone: Leave the Standalone field unchecked.
    • Type: Choose the type StandaloneVM.
    • Allow networking: Choose the desired Whonix-Gateway ProxyVM from the list. For example: sys-whonix.
    • Press: OK.
    • Make sure this workstation has enough private storage (StandaloneVM). You can estimate how much space you need by checking the size of the raw blockchain. Keep in mind that the blockchain will take up more space over time.

Qubes qrexec Policy Configuration

[edit]

1 Open Qubes Policy Editor

Qubes App Launcher (blue/grey "Q")Settings ButtonQubes ToolsQubes Policy Editor

2 Create new policy file

FileNew, for example 20-user

3 Allow network connection from wallet to monerod VM

Write qubes.ConnectTCP +18081 monero-wallet-ws monerod-ws allow in the newly created config file

4 Click Save and Exit

monerod-ws VM Configuration

[edit]

Note: The following instructions should be applied in Whonix-Workstation (Qubes-Whonix: App Qube monerod-ws).

1 Create folder ~/.config/systemd/user.

mkdir -p ~/.config/systemd/user

2 Create file ~/.config/systemd/user/monerod.service.

Open file ~/.config/systemd/user/monerod.service in a text editor of your choice as a regular, non-root user.

If you are using a graphical environment, run. featherpad ~/.config/systemd/user/monerod.service

If you are using a terminal, run. nano ~/.config/systemd/user/monerod.service

3 Paste the following contents. [2]

TODO: This step assumes monerod is installed on the system, which is no longer true. You need to manually download the monerod binary and point the ExecStart to that binary.

[Unit] Description=Monero Full Node After=network.target [Service] Type=simple PIDFile=/home/user/.bitmonero/monerod.pid ## https://github.com/monero-project/monero/issues/5098 KillSignal=SIGKILL Environment=DNS_PUBLIC=tcp Environment=TORSOCKS_ALLOW_INBOUND=1 ExecStart=torsocks monerod --data-dir=/home/user/.bitmonero \ --no-igd --hide-my-port --pidfile=/home/user/.bitmonero/monerod.pid \ --log-file=/home/user/.bitmonero/bitmonero.log --p2p-bind-ip=127.0.0.1 \ --non-interactive Restart=always PrivateTmp=true [Install] WantedBy=default.target

4 Save and close file.

5 Reload systemd user instance.

systemctl --user daemon-reload

6 Optional: Enable autostart for the monerod systemd user service.

systemctl --user enable monerod

7 Start monerod systemd user instance.

systemctl --user restart monerod

8 Done.

The monerod systemd user service has been configured.

monero-wallet-ws VM Setup

[edit]

Note: The following instructions should be applied in Whonix-Workstation (Qubes-Whonix: App Qube monero-wallet-ws).

1 Open file /rw/config/rc.local in an editor with administrative ("root") rights.

1 Select your platform.

Non-Qubes-Whonix

2 Notes.

  • Sudoedit guidance: See Kicksecure logo Open File with Root RightsOnion network Logo for details on why using sudoedit improves security and how to use it.
  • Editor requirement: Close Featherpad (or the chosen text editor) before running the sudoedit command.

3 Open the file with root rights.

sudoedit /rw/config/rc.local

Qubes-Whonix

2 Notes.

  • Sudoedit guidance: See Kicksecure logo Open File with Root RightsOnion network Logo for details on why using sudoedit improves security and how to use it.
  • Editor requirement: Close Featherpad (or the chosen text editor) before running the sudoedit command.
  • Template requirement: When using Qubes-Whonix, this must be done inside the Template.

3 Open the file with root rights.

sudoedit /rw/config/rc.local

4 Notes.

  • Shut down Template: After applying this change, shut down the Template.
  • Restart App Qubes: All App Qubes based on the Template need to be restarted if they were already running.
  • Qubes persistence: See also Kicksecure logo Qubes PersistenceOnion network Logo
  • General procedure: This is a general procedure required for Qubes and is unspecific to Qubes-Whonix.

Others and Alternatives

2 Notes.

  • Example only: This is just an example. Other tools could achieve the same goal.
  • Troubleshooting and alternatives: If this example does not work for you, or if you are not using Whonix, please refer to Open File with Root Rights.

3 Open the file with root rights.

sudoedit /rw/config/rc.local

2 Append the following line at the bottom.

qvm-connect-tcp 18081:monerod-ws:18081

3 Save and close file.

4 Make the /rw/config/rc.local script executable.

sudo chmod +x /rw/config/rc.local

5 Restart the monero-wallet-ws VM.

6 Done.

The monero-wallet-ws VM setup has been completed.

Usage

[edit]

Introduction

[edit]

Note: On the host (Qubes users: in dom0).

The involved VMs need to be started using any usual method (using Qubes VM Manager (QVMM), starting a terminal emulator, or otherwise).

1 Start monerod-ws VM.

2 Expectations.

Nothing is expected to happen. monerod is a background service. To monitor it, see chapter monitoring.

3 Start monero-wallet-ws VM.

Note: The following instructions should be applied in Whonix-Workstation (Qubes-Whonix: App Qube monero-wallet-ws).

4 Start Monero Wallet. Either:

  • A) Start Monero Wallet GUI using any method (from the start menu, from the command line, or autostart), or
  • B) Start Monero Wallet CLI using any method.

5 Done.

The required VMs and Monero Wallet have been started.

Monero Wallet GUI First Time Setup

[edit]

This first time setup only needs to be performed once.

Optional. The user could also avoid using Monero Wallet GUI and use Monero Wallet CLI instead.

Monero Wallet GUI lacks support for multisig and offline signing.

Note: The following instructions should be applied in Whonix-Workstation (Qubes-Whonix: App Qube monero-wallet-ws).

1 Monero Wallet GUI → Choose Advanced Mode.

2 After Monero Wallet GUI has started, it will ask to create or restore a wallet as usual, which is unspecific to these instructions.

3 Configure Monero Wallet GUI to use local monerod (which is running in monerod-ws VM).

The following setting is called remote node. There is no need for concern. See footnote. [3]

Monero Wallet GUI should now be running. Go to: [4]

Connect to a remote nodeAdd Remote NodeAddress: 127.0.0.1Port: 18081

  • Daemon username: No modifications required. Leave empty.
  • Daemon password: No modifications required. Leave empty.
  • It is discouraged to select Mark as Trusted Daemon. [5]

Using a "remote node" in this case is safe, see footnote for an explanation why it is safe. [3]

(If Monero Wallet GUI was already started, these settings can be found under: SettingsNode)

4 Done.

Monero Wallet GUI First Time Setup has been completed.

Monero Wallet CLI First Time Setup

[edit]

Alternatively, Monero Wallet GUI can be used.

Note: The following instructions should be applied in Whonix-Workstation (Qubes-Whonix: App Qube monero-wallet-ws).

Start Monero Wallet CLI.

  • Outdated command. Requires monero-wallet-cli in /usr/bin.
    • monero-wallet-cli
  • Untested command:
    • flatpak run --command=monero-wallet-cli org.getmonero.Monero

Monero Wallet CLI is more "clever" and automatically detects the already available monerod. [6] Therefore, as opposed to Monero Wallet GUI, no "remote node" configuration is necessary.

This might not work easily with flatpak because the host listening port might not be visible from within the flatpak chroot. This will most likely require additional flatpak options.

Monitoring

[edit]

Note: The following instructions should be applied in Whonix-Workstation (Qubes-Whonix: App Qube monerod-ws).

Check the status of the monerod systemd user service.

systemctl --user status monerod

Follow the journal log of the monerod systemd user service.

journalctl --boot --user -f -u monerod

Follow the log file of monerod.

tail -f ~/.bitmonero/bitmonero.log

View the log file of monerod.

Open file ~/.bitmonero/bitmonero.log in a text editor of your choice as a regular, non-root user.

If you are using a graphical environment, run. featherpad ~/.bitmonero/bitmonero.log

If you are using a terminal, run. nano ~/.bitmonero/bitmonero.log

For the initial author of this wiki page, it took approximately 7 minutes from monerod logging SYNCHRONIZATION started until further synchronization progress was actually reported.

2021-11-02 10:53:55.204	[P2P4]	INFO	global	src/cryptonote_protocol/cryptonote_protocol_handler.inl:413	SYNCHRONIZATION started
2021-11-02 11:00:20.821	[P2P9]	INFO	global	src/cryptonote_protocol/cryptonote_protocol_handler.inl:1680	Synced 201/2484385 (0%, 2484184 left)

See Also

[edit]

Donations

[edit]

After setting up Monero with wallet isolation, please consider making a donation to the Monero and Whonix projects (Donate) to help keep them running for many years to come.

Monero accepted here Donate Monero (XMR) to Whonix.

84ZZSsqyh5niztCgxmWAejDLu9eDerWo4Wsx8woEhDGpdKP3BWPtqenNjKuv8vojrB968U3hqYTKgLGt2zEcGopX1qaEPew

Footnotes

[edit]
  1. The systemctl --user must be run as a normal, non-root user without sudo because these are systemd user units and not systemd system units.
  2. Do not use --detach - outdated style for daemons. Error handling is better without it.
  3. 3.0 3.1 This is safe, because the connection will be made from Monero Wallet in the monero-wallet-ws VM to a self-hosted monerod server running in the monerod-ws VM.
  4. Monero Wallet GUI fails to detect already running monerodarchive.org iconarchive.today icon
  5. Benefits would need to be researched, and why trust if not needed.
  6. monero-wallet-cli detects that monerod's default port 18081 is open on localhost. The detection mechanism is port based, not process based.
Notification image

We believe security software like Whonix needs to remain open source and independent. Would you help sustain and grow the project? Learn more about our 14 year success story and maybe DONATE!